home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / pascal / xmm12.zip / XMM.PAS < prev    next >
Pascal/Delphi Source File  |  1992-07-05  |  45KB  |  927 lines

  1.   {--------------------------------------------------------------------------
  2.      UNIT :          XMM                           INITIAL : 19891127 v 1.00
  3.      AUTHOR :        Jeroen W. Pluimers            UPDATE :  19920705 v 1.20
  4.  
  5.      DESCRIPTION :   eXpanded Memory Manager
  6.  
  7.      HISTORY :       19891127 - 1.00 - jwp
  8.  
  9.                          initial translation from XMS 2.0 specification
  10.  
  11.                      19909322 - 1.11 - jwp
  12.  
  13.                          final XMS 2.0 implementation
  14.  
  15.                      19920705 - 1.20 - jwp
  16.  
  17.                          incorporation of XMS 3.0 specification
  18.  
  19.      COMPUTER :      NEAT-AT, ERC 386/25
  20.      COMPILER :      TURBO PASCAL 5.0, 5.5 and 6.0
  21.  
  22.      COPYRIGHT :     (c) 1989-1992 Pluimers Software Ontwikkeling.
  23.    --------------------------------------------------------------------------}
  24.  
  25. Unit XMM;
  26.  
  27. {$I Directive.Inc }
  28.  
  29. Interface
  30.  
  31. Type
  32.   XMMMoveRec = Record Case Boolean of
  33.     False : (Length       : Longint;  { 32-bit number of bytes to transfer   }
  34.              SourceHandle : Word;     { Handle of source block               }
  35.              SourceOffset : Longint;  { 32-bit offset into source            }
  36.              DestHandle   : Word;     { Handle of destination block          }
  37.              DestOffset   : Longint;  { 32-bit offset into destination block }
  38.             );
  39.    True   : (TheLenght    : Longint;  { note that the lenght must be even !  }
  40.              ZeroSource   : Word;     { zero sourcehandle means a seg:ofs    }
  41.              SourcePtr    : Pointer;  { pointer to "normal" memory           }
  42.              ZeroDest     : Word;     { zero dest handle means a seg:ofs     }
  43.              DestPtr      : Pointer;  { pointer to "normal" memory           }
  44.             );
  45.   End; { XMMMoveRec }
  46.  
  47. Const
  48.  
  49.   XMMOk              = $00;{ function succeeded.                              }
  50.  
  51.   XMMNotImplemented  = $80;{ the function is not implemented.                 }
  52.   XMMVDiskFound      = $81;{ a VDISK device is detected.                      }
  53.   XMMA20Err          = $82;{ an A20 error occurs.                             }
  54.   XMMGenErr          = $8E;{ a general driver error occurs.                   }
  55.   XMMUnrecovErr      = $8F;{ an unrecoverable driver error occurs.            }
  56.  
  57.   XMMHMAnotExist     = $90;{ the HMA does not exist.                          }
  58.   XMMHMAInUse        = $91;{ the HMA is already in use.                       }
  59.   XMMHMAminSize      = $92;{ DX is less than the /HMAMIN= parameter.          }
  60.   XMMHMANotAlloced   = $93;{ the HMA is not allocated.                        }
  61.   XMMA20StillEnabled = $94;{ the A20 line is still enabled.                   }
  62.  
  63.   XMMOutOfMemory     = $A0;{ all extended memory is allocated.                }
  64.   XMMOutOfHandles    = $A1;{ all available extended memory handles are in use.}
  65.   XMMInvalidHandle   = $A2;{ the handle is invalid.                           }
  66.   XMMSourceHanldeInv = $A3;{ the SourceHandle is invalid.                     }
  67.   XMMSourceOffsetInv = $A4;{ the SourceOffset is invalid.                     }
  68.   XMMDestHanleInv    = $A5;{ the DestHandle is invalid.                       }
  69.   XMMDestOffset      = $A6;{ the DestOffset is invalid.                       }
  70.   XMMLenInv          = $A7;{ the Length is invalid.                           }
  71.   XMMOverlap         = $A8;{ the move has an invalid overlap.                 }
  72.   XMMParity          = $A9;{ a parity error occurs.                           }
  73.   XMMEMBUnlocked     = $AA;{ the block is not locked.                         }
  74.   XMMEMBLocked       = $AB;{ the block is locked.                             }
  75.   XMMLockOverflow    = $AC;{ the block's lock count overflows.                }
  76.   XMMLockFail        = $AD;{ the lock fails.                                  }
  77.  
  78. Function XMMInstalled : Boolean;
  79.   {---------------------------------------------------------------------------
  80.      ROUTINE :     XMMInstalled
  81.  
  82.      DESCRIPTION : THIS ROUTINE MUST BE CALLED BEFORE ANY OTHER ROUTINE
  83.                    OR ALL THE OTHER ROUTINES WILL FAIL WITH ERROR CODE $80.
  84.  
  85.      RETURNS :     False - No XMM driver found.
  86.                    True  - An XMM driver has been found.
  87.  
  88.      POST :        Internal pointer to XMM driver is established.
  89.    ---------------------------------------------------------------------------}
  90.  
  91. Function XMMVersion(Var XMSversion,
  92.                         XMSrevision  : Word;
  93.                     Var HMAAvailable : Boolean) : Byte;
  94.   {---------------------------------------------------------------------------
  95.      ROUTINE :     XMMVersion
  96.  
  97.      DESCRIPTION : Get version numbers. Both the XMS version number and the
  98.                    driver internal revision number are encoded as follows :
  99.                      Low byte  = minor part.
  100.                      High byte = major part.
  101.                    e.g. XMSversion $0277 would mean version 2.77.
  102.                    The HMAAvailable indicates the existence of the HMA (not
  103.                    its availability) and is intended mainly for installation
  104.                    programs.
  105.  
  106.      OUT :         XMSversion   - XMS version number.
  107.                    XMSrevision  - Driver internal revision number.
  108.                    HMAAvailable - False - no HMA detected.
  109.                                   True  - HMA has been detected.
  110.  
  111.      RETURNS :     XMMOk              - Always if XMMInstalled has been called.
  112.                    XMMNotImplemented  - XMMInstalled has not been called.
  113.  
  114.      PRE :         XMMInstalled must have been called first.
  115.    ---------------------------------------------------------------------------}
  116.  
  117. Function XMMRequestHMA (SpaceNeeded : Word) : Byte;
  118.   {---------------------------------------------------------------------------
  119.      ROUTINE :     XMMRequestHMA
  120.  
  121.      DESCRIPTION : Attempts to reserve the whole 64K-16 byte high memory
  122.                    area for the caller.
  123.                    If the HMA is currently unused, the caller's size
  124.                    parameter is compared to the /HMAMIN= parameter on
  125.                    the driver's command line.
  126.                    If the value passed by the caller is greater than or
  127.                    equal to the amount specified by the driver's
  128.                    parameter, the request succeeds.
  129.                    This provides the ability to ensure that programs
  130.                    which use the HMA efficiently have priority over
  131.                    those which do not.
  132.                    NOTE: See the sections "Prioritizing HMA Usage" and
  133.                          "High Memory Area Restrictions" in the
  134.                          documentation for more information.
  135.  
  136.      IN :          SpaceNeeded - Number of bytes in the HMA needed by caller.
  137.                                  It is recommended that if the caller is
  138.                                  an application program this value is
  139.                                  set to 65535 and if the caller is a TSR
  140.                                  the real number of bytes is used.
  141.  
  142.      RETURNS :     XMMOk              - the HMA is assigned to the caller.
  143.                    XMMNotImplemented  - the function is not implemented.
  144.                    XMMVDiskFound      - a VDISK device is detected.
  145.                    XMMHMANotExist     - the HMA does not exist.
  146.                    XMMHAMInUse        - the HMA is already in use.
  147.                    XMMHAMMinSize      - SpaceNeeded is less than the /HMAMIN=
  148.                                         environment parameter.
  149.  
  150.      PRE :         XMMInstalled must have been called first.
  151.    ---------------------------------------------------------------------------}
  152.  
  153. Function XMMReleaseHMA : Byte;
  154.   {---------------------------------------------------------------------------
  155.      ROUTINE :     XMMReleaseHMA
  156.  
  157.      DESCRIPTION : Releases the high memory area and allows other
  158.                    programs to use it.
  159.                    Programs which allocate the HMA must release it
  160.                    before exiting.
  161.                    When the HMA has been released,